<template>
  <e-table
    ref="eTable"
    @getList="handleGetList"
    :tableData="tableData"
    :columns="columns"
    :loading="loading"
    :pageObj="null"
  >
    <el-table-column label="科室收入增长率" slot="incForShowIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.inc_for_show_ir < 0 ? 'green' : '' , scope.row.inc_for_show_ir > 0 ? 'red' : '' ]"
        >{{ scope.row.inc_for_show_ir }}</span>
      </template>
    </el-table-column>
    <el-table-column label="人均费用增长率" slot="perAvgCostIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.per_avg_cost_ir < 0 ? 'green' : '' , scope.row.per_avg_cost_ir > 0 ? 'red' : '' ]"
        >{{ scope.row.per_avg_cost_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="单床产值增长率" slot="singleBedValueIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.single_bed_value_ir < 0 ? 'red' : '' , scope.row.single_bed_value_ir > 0 ? 'green' : '' ]"
        >{{ scope.row.single_bed_value_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="人均治疗收入增长率" slot="perTreatIncIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.per_treat_inc_ir < 0 ? 'red' : '' , scope.row.per_treat_inc_ir > 0 ? 'green' : '' ]"
        >{{ scope.row.per_treat_inc_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="医技收入占比增长率" slot="techIncPctIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.tech_inc_pct_ir < 0 ? 'red' : '' , scope.row.tech_inc_pct_ir > 0 ? 'green' : '' ]"
        >{{ scope.row.tech_inc_pct_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="药品收入占比增长率" slot="drugPctIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.drug_pct_ir < 0 ? 'green' : '' , scope.row.drug_pct_ir > 0 ? 'red' : '' ]"
        >{{ scope.row.drug_pct_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="耗占比增长率" slot="consumpPctIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.consump_pct_ir < 0 ? 'green' : '' , scope.row.consump_pct_ir > 0 ? 'red' : '' ]"
        >{{ scope.row.consump_pct_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="出院人次增长率" slot="outPersonNumIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.out_person_num_ir < 0 ? 'red' : '' , scope.row.out_person_num_ir > 0 ? 'green' : '' ]"
        >{{ scope.row.out_person_num_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="住院天数增长率" slot="innerDayIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.inner_day_ir < 0 ? 'green' : '' , scope.row.inner_day_ir > 0 ? 'red' : '' ]"
        >{{ scope.row.inner_day_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="平均住院日增长率" slot="innerAvgDayIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.inner_avg_day_ir < 0 ? 'green' : '' , scope.row.inner_avg_day_ir > 0 ? 'red' : '' ]"
        >{{ scope.row.inner_avg_day_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="增长率" slot="actualOpenBedNumIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.actual_open_bed_num_ir < 0 ? 'green' : '' , scope.row.actual_open_bed_num_ir > 0 ? 'red' : '' ]"
        >{{ scope.row.actual_open_bed_num_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="床位周转次数增长率" slot="bedTurnoverNumIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.bed_turnover_num_ir < 0 ? 'red' : '' , scope.row.bed_turnover_num_ir > 0 ? 'green' : '' ]"
        >{{ scope.row.bed_turnover_num_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="病床使用率增长率" slot="bedUseRateIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.bed_use_rate_ir < 0 ? 'red' : '' , scope.row.bed_use_rate_ir > 0 ? 'green' : '' ]"
        >{{ scope.row.bed_use_rate_ir }}</span>
      </template>
    </el-table-column>

    <el-table-column label="手术人次增长率" slot="operNumIr" align="center">
      <template slot-scope="scope">
        <span
          :class="[ scope.row.oper_num_ir < 0 ? 'red' : '' , scope.row.oper_num_ir > 0 ? 'green' : '' ]"
        >{{ scope.row.oper_num_ir }}</span>
      </template>
    </el-table-column>
  </e-table>
</template>

<script>
import { reportTableByMonth } from '@/api/reports'
export default {
  props: {
    columns: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      total: 1,
      loading: false,
      tableData: []
    }
  },
  methods: {
    async handleGetList(param = {}) {
      this.loading = true
      const res = await reportTableByMonth({ ...this.queryParam, ...param })

      if (res && res.data.length > 0) {
        const { state, data } = res
        this.tableData = data
      } else {
        this.tableData = []
      }
      this.loading = false
    }
  }
}
</script>
